/*
 * @Author: YuanQuan D
 * @Date: 2025-03-24 15:59:22
 * @LastEditTime: 2025-04-02 07:03:19
 * @FilePath: \F429_arm_control_slave\User_Code\Inc\pc_interaction.h
 */
#ifndef _PC_INTERACTION_H_
#define _PC_INTERACTION_H_

#include "main.h"
#include "cmsis_os.h"

#define slave_rev_frame_head 0xAA
#define slave_rev_frame_tail 0x55
#define slave_rev_RMD_Motor 0x01
#define slave_rev_Joint_Motor 0x02
#define slave_rev_Mix_Motor 0x03
#define slave_rev_tendon 0x04
#define usb_imu_flag 0x88
#define slave_rev_RMD1_ID 0x00
#define slave_rev_RMD2_ID 0X02
#define slave_rev_Joint1_ID 0x01
#define slave_rev_Joint2_ID 0x02
#define RMD_Max_SPEED 500
#define Joint_Max_SPEED 100
#define Joint_Max_acc 1
#define RMD1_ang_min 180 
#define RMD1_ang_max 360
#define Joint1_ang_min 160  //向后
#define Joint1_ang_max 270  //向前
#define Joint2_ang_min 90   //向右
#define Joint2_ang_max 187  //向左

#define Joint_1_Forward_90_ang 270
#define Joint_1_Forward_50_ang 230
#define Joint_1_Forward_30_ang 210
#define Joint_1_Backward_20_ang 160
#define Joint_2_Turn_Right_90_ang 90
#define Joint_2_Turn_Right_60_ang 120
#define Joint_2_Turn_Right_45_ang 135

#define Joint_1_Init_ang 180
#define Joint_2_Init_ang 180
#define RMD_1_Init_ang 270
#define RMD_2_Init_ang 180

#define HWT901_LEN 39
#define polhemux_LEN 60
#define M_ang_LEN 8
#define ppv_data_len 28
#if polhemux_get_flag && imu_bluetooth_use_flag
    #define ToGUI_DataLEN (HWT901_LEN + polhemux_LEN + M_ang_LEN + ppv_data_len)
#else
    #define ToGUI_DataLEN (M_ang_LEN + ppv_data_len + 3)
#endif

#define tx_send_finish_event (0x01 << 0)   //设置事件掩码的位 0 
#define tx_gui_time_event (0x01 << 1)  //设置事件掩码的位 1

#define deal_ang_time_event (0x01 << 0)

#define ang_ctr_time_event (0x01 << 0)

#define tx_slave_time_event (0x01 << 0)
#define tx_slave_value_calculate_done_event (0x01 << 1)
#define tx_slave_finish_event (0x01 << 2)

#define rx_slave_time_event (0x01 << 0)

void ToPC_dataPack();
void rev_pc_data_analysis(void);
void GUI_communication_init(void);

#endif